package com.orcs.leefei.utils.kotlin

import android.graphics.drawable.Drawable
import android.support.v7.widget.AppCompatDrawableManager
import android.widget.TextView

/**
 *
 * Created by FeiLee on 2017/1/4 01:28.
 */

inline fun TextView.drawableLeft(drawableRes: Int) {
    setCompoundDrawablesWithIntrinsicBounds(
            AppCompatDrawableManager.get().getDrawable(context, drawableRes),
            null,
            null,
            null)


}

inline fun TextView.drawableLeft(left: Drawable) {
    setCompoundDrawablesWithIntrinsicBounds(left, null, null, null)
}

inline fun TextView.drawableTop(drawableRes: Int) {
    setCompoundDrawablesWithIntrinsicBounds(
            null,
            AppCompatDrawableManager.get().getDrawable(context, drawableRes),
            null,
            null)
}

inline fun TextView.drawableTop(drawableRes: Int, tintColor: Int) {
    val drawable = AppCompatDrawableManager.get().getDrawable(context, drawableRes)
    drawable.tintColor(tintColor)
    setCompoundDrawablesWithIntrinsicBounds(
            null,
            drawable,
            null,
            null)
}
